-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only attempt to copy resources that still exist from scenes #9984
Only attempt to copy resources that still exist from scenes #9984
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Should we emit a warning here as well?
@alice-i-cecile, as in log a warning that we've hit this edge case? I don't think this represents any mistake from the consumer (IIUC a removed resource shouldn't be visible externally; we just keep the storage around as an optimisation). |
Yep, that was my intent. Great: I think I'm convinced by your argument here. |
…ne#9984) # Objective Avert a panic when removing resources from Scenes. ### Reproduction Steps ```rust let mut scene = Scene::new(World::default()); scene.world.init_resource::<Time>(); scene.world.remove_resource::<Time>(); scene.clone_with(&app.resource::<AppTypeRegistry>()); ``` ### Panic Message ``` thread 'Compute Task Pool (10)' panicked at 'Requested resource bevy_time::time::Time does not exist in the `World`. Did you forget to add it using `app.insert_resource` / `app.init_resource`? Resources are also implicitly added via `app.add_event`, and can be added by plugins.', .../bevy/crates/bevy_ecs/src/reflect/resource.rs:203:52 ``` ## Solution Check that the resource actually still exists before copying. --- ## Changelog - resolved a panic caused by removing resources from scenes
…ne#9984) # Objective Avert a panic when removing resources from Scenes. ### Reproduction Steps ```rust let mut scene = Scene::new(World::default()); scene.world.init_resource::<Time>(); scene.world.remove_resource::<Time>(); scene.clone_with(&app.resource::<AppTypeRegistry>()); ``` ### Panic Message ``` thread 'Compute Task Pool (10)' panicked at 'Requested resource bevy_time::time::Time does not exist in the `World`. Did you forget to add it using `app.insert_resource` / `app.init_resource`? Resources are also implicitly added via `app.add_event`, and can be added by plugins.', .../bevy/crates/bevy_ecs/src/reflect/resource.rs:203:52 ``` ## Solution Check that the resource actually still exists before copying. --- ## Changelog - resolved a panic caused by removing resources from scenes
…ne#9984) # Objective Avert a panic when removing resources from Scenes. ### Reproduction Steps ```rust let mut scene = Scene::new(World::default()); scene.world.init_resource::<Time>(); scene.world.remove_resource::<Time>(); scene.clone_with(&app.resource::<AppTypeRegistry>()); ``` ### Panic Message ``` thread 'Compute Task Pool (10)' panicked at 'Requested resource bevy_time::time::Time does not exist in the `World`. Did you forget to add it using `app.insert_resource` / `app.init_resource`? Resources are also implicitly added via `app.add_event`, and can be added by plugins.', .../bevy/crates/bevy_ecs/src/reflect/resource.rs:203:52 ``` ## Solution Check that the resource actually still exists before copying. --- ## Changelog - resolved a panic caused by removing resources from scenes
…ne#9984) # Objective Avert a panic when removing resources from Scenes. ### Reproduction Steps ```rust let mut scene = Scene::new(World::default()); scene.world.init_resource::<Time>(); scene.world.remove_resource::<Time>(); scene.clone_with(&app.resource::<AppTypeRegistry>()); ``` ### Panic Message ``` thread 'Compute Task Pool (10)' panicked at 'Requested resource bevy_time::time::Time does not exist in the `World`. Did you forget to add it using `app.insert_resource` / `app.init_resource`? Resources are also implicitly added via `app.add_event`, and can be added by plugins.', .../bevy/crates/bevy_ecs/src/reflect/resource.rs:203:52 ``` ## Solution Check that the resource actually still exists before copying. --- ## Changelog - resolved a panic caused by removing resources from scenes
Objective
Avert a panic when removing resources from Scenes.
Reproduction Steps
Panic Message
Solution
Check that the resource actually still exists before copying.
Changelog